<template>
  <div>
    <h1>当前求和为：{{ $store.state.categoryAbout.sum }}</h1>
    <h3>bigSum：{{ $store.getters['categoryAbout/bigSum'] }}</h3>
    <div>
      <select v-model="initValue">
        <option :value="1">1</option>
        <option :value="2">2</option>
        <option :value="3">3</option>
      </select>
      <button @click="increment(initValue)">+</button>
      <button @click="decrement(initValue)">-</button>
      <button @click="incrementOdd(initValue)">当前求和为奇数再加</button>
      <button @click="incrementDelay(initValue)">延迟1秒再加</button>
    </div>
    <h1>PersonList组件的总人数为：{{ $store.state.personAbout.personList.length }}</h1>
  </div>
</template>

<script>
export default {
  name: 'MyCategory', 
  data() {
    return {
      initValue: 1
    }
  },
  methods: {
    increment() {
      this.$store.commit('categoryAbout/INCREMENT', this.initValue)
    },
    decrement() {
      this.$store.commit('categoryAbout/DECREMENT', this.initValue)
    },
    incrementOdd() {
      this.$store.dispatch('categoryAbout/incrementOdd', this.initValue)
    },
    incrementDelay() {
      this.$store.dispatch('categoryAbout/incrementDelay', this.initValue)
    },
  }
}
</script>